package com.theory.session;

import com.theory.builder.XmlConfigBuilder;
import com.theory.config.Configuration;

import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    /**
     * read the xml , init the configuration, and build a factory
     */
    public SqlSessionFactory build(InputStream inputStream){
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder(inputStream);
        return build(xmlConfigBuilder.parse());
    }

    public SqlSessionFactory build(Configuration configuration){
        return new DefaultSqlSessionFactory(configuration);
    }
}
